<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:rich="http://richfaces.org/rich">
	<body>

		<ui:composition template="/template/template.xhtml">
		
		  <ui:define name="title">Consultar Veiculos</ui:define>
		  
		  <ui:define name="body">	
		  
		    <h:form id="form">
				<h:panelGrid styleClass="panelGrid">
				
					<h:panelGrid columns="3">
						<h:panelGrid>
							<h:outputLabel value="Placa:" for="placa" />
							<h:inputText id="placa" name="placa" value="#{crudVeiculo.veiculoTO.placa}"/>
						</h:panelGrid>
						<h:panelGrid>
							<h:outputLabel value="Descricao:" for="descricao" />
							<h:inputText id="descricao" name="descricao" value="#{crudVeiculo.veiculoTO.descricao}" />
						</h:panelGrid>					
						<h:panelGrid>
							<h:outputLabel value="Tipo Veiculo:" for="tipoVeiculo" />
							<h:selectOneMenu id="tipoVeiculo" value="#{crudVeiculo.veiculoTO.tipoVeiculo}" converter="simpleConvert" styleClass="tamanhoMedio">
								<f:selectItems value="#{crudVeiculo.tiposVeiculos}" />
							</h:selectOneMenu>
						</h:panelGrid>
					</h:panelGrid>
					
					<h:panelGrid columns="2">
						<h:panelGrid>
							<h:outputLabel for="cliente" value="Cliente:"></h:outputLabel>
							<h:selectOneMenu id="cliente" value="#{crudVeiculo.veiculoTO.cliente}" converter="simpleConvert" styleClass="tamanhoMedio">
								<f:selectItems value="#{crudVeiculo.clientes}" />
							</h:selectOneMenu>
						</h:panelGrid>
						<h:panelGrid>
							<h:outputLabel for="status" value="Status:"></h:outputLabel>
							<h:selectOneMenu id="status" value="#{crudVeiculo.statusValue}" styleClass="tamanhoMedio">
								<f:selectItems value="#{crudVeiculo.listaStatus}" />
							</h:selectOneMenu>
						</h:panelGrid>
					</h:panelGrid>

					<h:panelGrid columns="2">
						<h:commandButton value="incluir" action="#{crudVeiculo.goIncluir}" styleClass="button"/>
						<h:commandButton value="consultar" action="#{crudVeiculo.consultar}" styleClass="button"/>
					</h:panelGrid>

					
					<h:dataTable rendered="#{crudVeiculo.exibirTabela}" value="#{crudVeiculo.veiculos}" var="item" styleClass="tabela" width="100%" rowClasses="even, odd">
						<h:column>
							<f:facet name="header">
								<h:outputText value="Placa" />
							</f:facet>
							<h:outputText value="#{item.placa}"></h:outputText>
						</h:column>
						<h:column>
							<f:facet name="header">
								<h:outputText value="Descricao" />
							</f:facet>
							<h:outputText value="#{item.descricao}"></h:outputText>
						</h:column>
						<h:column>
							<f:facet name="header">
								<h:outputText value="Cliente" />
							</f:facet>
							<h:outputText value="#{item.cliente.nome}"></h:outputText>
						</h:column>	
						<h:column>
							<f:facet name="header">
								<h:outputText value="Status" />
							</f:facet>
							<h:outputText value="#{item.status}"></h:outputText>
						</h:column>	
						<h:column>
							<f:facet name="header">
								<h:outputText value="Acao" />
							</f:facet>
							<h:commandLink value="editar"
								actionListener="#{crudVeiculo.goEditar}">
								<f:param name="id" id="id" value="#{item.id}"></f:param>
							</h:commandLink>
							<br/>
							<h:commandLink value="remover"
								actionListener="#{crudVeiculo.remover}">
								<f:param name="id" id="id" value="#{item.id}"></f:param>
							</h:commandLink>
						</h:column>						
					</h:dataTable>
				</h:panelGrid>
		    </h:form>
		  </ui:define>
		
		</ui:composition>

	</body>
</html>